package com.ljh.blog.pojo.response;

import com.ljh.blog.enums.ResultCodeEum;
import lombok.Data;

/**
 * @author: Themberfue
 * @date: 2025/3/30 18:52
 * @description:
 */

@Data
public class Result {
    private ResultCodeEum code;
    private String errMsg;
    private Object data;

    public static Result success(Object data) {
        Result result = new Result();
        result.setCode(ResultCodeEum.SUCCESS);
        result.setData(data);
        return result;
    }

    public static Result fail(String errMsg) {
        Result result = new Result();
        result.setCode(ResultCodeEum.FAIL);
        result.setErrMsg(errMsg);
        return result;
    }

    public static Result fail(String errMsg, Object data) {
        Result result = fail(errMsg);
        result.setData(data);
        return result;
    }
}
